package com.ixoko.swagger.controller.base;

import com.ixoko.swagger.dto.BaseResDto;
import com.ixoko.swagger.enums.ErrorCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luojie
 * @Date 2018/7/1
 */
@ControllerAdvice
@RestController
public class AdviceController {

    @ExceptionHandler(Exception.class)
    public BaseResDto<Object> exception(Exception e) {
        BaseResDto<Object> resDto = new BaseResDto<>();
        resDto.setFlag(false);
        resDto.setError(ErrorCode.E000001.getCode(), e.getMessage());
        return resDto;
    }
}
